/**
 * @see https://leetcode-cn.com/problems/sum-of-square-numbers/
 * @param {number} c
 * @return {boolean}
 */
var judgeSquareSum = function(c) {
  // let target = Math.floor(Math.sqrt(c));
  let target = Math.floor(c/2);
  let from = 0;
  let result = false;
  console.log(target)
  while(from <= target) {
    let sum = Math.pow(from, 2) + Math.pow(target, 2);
    if(sum === c) {
      result = true;
      break;
    }
    if(sum > c) {
      target--;
    }
    if(sum < c) {
      from++;
    }
  }
  return result
};

console.time('begin')
console.log(judgeSquareSum(865656685))
console.timeEnd('begin')